package com.sky.web.app;

import com.sky.constant.StatusConstant;
import com.sky.dto.CategoryDTO;
import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userCategoryController")
@RequestMapping("/user/category")
public class CategoryController {

    @Autowired
    CategoryService categoryService;

    /**
     * 查询全部启用状态的分类列表
     * @return
     */
    @GetMapping("/list")
    public Result list(){
        //封装查询条件
        CategoryDTO categoryDTO = CategoryDTO.builder()
                .status(StatusConstant.ENABLE)
                .build();
        //查询
        List<Category> list = categoryService.list(categoryDTO);
        return Result.success(list);
    }
}
